﻿#define _CRT_SECURE_NO_WARNINGS//水仙花数
#include<stdio.h>
#include<math.h>
sui(int i, int m)
{
	if (i > 10)
	{
		int n = 0;
		n = i % 10;
		i /= 10;
		return pow(n, m) + sui(i, m);
	}
	else
		return pow(i, m);

}
int main()
{
	int n = 0;
	int c = 0;
	for (int i = 0; i <= 100000; i++)
	{
		if (i == 0)
		{
			printf("0\n");
		}
		n = 0;
		c = i;
		while (i)
		{
			i /= 10;
			n += 1;

		}
		i = c;
		int b = sui(i, n);
		if (b == i)
		{
			printf("%d\n", i);
		}

	}
	return 0;
}